package com.terrynoya.display
{
	import com.terrynoya.collision.ICollision;
	
	import flash.display.Graphics;
	import flash.display.Sprite;
	
	public class MRect extends Sprite implements ICollision
	{
		private var _width:Number;
		
		private var _color:uint;
		
		private var _collision:Boolean = false;
		
		public function MRect(width:int)
		{
			super();
			this._width = width;
			this.draw();
			
		}
		
		public function set collision(value:Boolean):void
		{
			this._collision = value;
			this.updateColor();
			this.draw();
		}
		
		public function updateColor():void
		{
			this._collision == true? this._color = 0xff0000 : this._color = 0x0;
		}
		
		public function get collision():Boolean
		{
			return this._collision;
		}

		public function get color():uint
		{
			return _color;
		}

		public function set color(value:uint):void
		{
			_color = value;
			this.draw();
		}

		private function draw():void
		{
			var g:Graphics = this.graphics;
			g.clear();
			g.beginFill(this._color);
			g.drawRect(0,0,this._width,this._width);
			g.endFill();
			this.alpha = 0.5;
		}
	}
}